<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddReceiptResponseToCollectionApiRequests extends Migration
{
    protected $table = "collection_api_requests";
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table($this->table, function (Blueprint $table) {
            $table->integer('receipt_response_code')->index()->default(0)->comment('回执响应码');
            $table->string('receipt_response_data')->default(json_encode([]))->comment('回执响应具体数据');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if(Schema::hasTable($this->table)){
            Schema::table($this->table, function (Blueprint $table) {
                $table->dropColumn('receipt_response_code');
                $table->dropColumn('receipt_response_data');
            });
        }
    }
}
